package com.dylan;

public class Test01 {

	/**
	 * @date Sep 28, 2012
	 * @param args
	 */
	public static void main(String[] args) {
//		String ipStr = new String("192.168.1.1");
//		ScopeSplit(ipStr);
//		LocationSplit(ipStr);
//		MultiSplit(ipStr);
//		EspecialSplit(ipStr);
//		GroupSplit("ABC1EDF2UU");
//		GroupSplit("1Af3EDC");
		
		String str = "abcdefefefg1h";
//		System.out.println(str.matches("[a-zA-Z0-9]*[ef]{3}[a-zA-Z0-9]*"));
		System.out.println(str.matches("^abc[a-zA-Z0-9]*"));
	}

	public static void ScopeSplit(String text) {

		String[] resultStr = text.split("[12]");
		System.out.println(resultStr.length);
		if (resultStr.length > 0) {
			int i = 0;
			for (String temp : resultStr)
				System.out.println("lien[" + (++i) + "] = " + temp);
		}
		System.out.println("/************************/");
	}

	public static void LocationSplit(String text) {
		System.out.println("start with '1'");
		String[] resultStr = text.split("^1");
		System.out.println(resultStr.length);
		if (resultStr.length > 0) {
			int i = 0;
			for (String temp : resultStr)
				System.out.println("lien[" + (++i) + "] = " + temp);
		}
		System.out.println("/************************/");
		System.out.println("end with '2'");
		String[] resultStr2 = text.split("2$");
		System.out.println(resultStr2.length);
		if (resultStr2.length > 0) {
			int i = 0;
			for (String temp : resultStr2)
				System.out.println("lien[" + (++i) + "] = " + temp);
		}
		System.out.println("/************************/");
	}
	
	public static void MultiSplit(String text) {

		String[] resultStr = text.split("1|2");
		System.out.println(resultStr.length);
		if (resultStr.length > 0) {
			int i = 0;
			for (String temp : resultStr)
				System.out.println("lien[" + (++i) + "] = " + temp);
		}
		System.out.println("/************************/");
	}
	
	public static void EspecialSplit(String text) {
		System.out.println("\\011 = " + 011);
		String[] resultStr = text.split("\071");
		System.out.println(resultStr.length);
		if (resultStr.length > 0) {
			int i = 0;
			for (String temp : resultStr)
				System.out.println("lien[" + (++i) + "] = " + temp);
		}
		System.out.println("/************************/");
	}
	
	public static void GroupSplit(String text) {
		System.out.println("1AF3EDC");
//		String[] resultStr = text.split("([A-Z]{3})\\d");
		String resultStr = text.replaceAll("(?:\\d|[A-Z])\\w", "(temp)"); 
		/*System.out.println(resultStr.length);
		if (resultStr.length > 0) {
			int i = 0;
			for (String temp : resultStr)
				System.out.println("lien[" + (++i) + "] = " + temp);
		}*/
		System.out.println(resultStr);
		System.out.println("/************************/");
	}
	
}
